package com.nl.controller.web.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nl.controller.common.annotation.SystemServiceLog;
import com.nl.controller.common.model.OperatorLog;
import com.nl.controller.web.mapper.TestMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestService {

    @Autowired
    private TestMapper testMapper;

    @SystemServiceLog(description = "测试插入日志数据")
    public void test() {
        System.out.println("test");
    }

    @SystemServiceLog(value = false, description = "测试分页查询日志")
    public List<OperatorLog> queryLog(int pageNo, int pageSize) {
        PageHelper.startPage(pageNo, pageSize);
        List<OperatorLog> list = testMapper.queryOperatorLogList();
        PageInfo<OperatorLog> pageInfo = new PageInfo<>(list);
        long total = pageInfo.getTotal();
        System.out.println("共有商品信息：" + total);
        return pageInfo.getList();
    }
}
